﻿// Copyright 2008 (c) Michael Reichenauer, SWEDEN. All rights reserved.
//---------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PSMock.Implementation;

namespace PSMock
{



	/// <summary>
	/// Options for mocked methods, where argument types have not been specified, e.g.
	/// <code>
	/// Mock.Method(() => { mocked.Set(); })
	///   .Throw(new InvalidOpweationException());
	/// </code>
	/// </summary>
	public class MethodOption : Option
	{
		public MethodOption(MockedFunction mockedFunction) 
			: base(mockedFunction) { }

		public Option Condition(Func<bool> predicate)
		{
			mockedFunction.Condition = predicate;
			return this;
		}
		public Option Do(Action method)
		{
			mockedFunction.Function = method;
			return this;
		}
	}


	/// <summary>
	/// Options for mocked methods, where argument types have been specified, e.g.
	/// <code>
	/// Mock.Method&lt;string&gt;(mocked.Set)
	///   .Do(s => { throw new InvalidOpweationException(); });
	/// </code>
	/// </summary>
	/// <typeparam name="T1">The type of the 1.</typeparam>
	public class MethodOption<T1> : Option
	{
		public MethodOption(MockedFunction mockedFunction) 
			: base(mockedFunction) { }

		/// <summary>
		/// Conditions for mocking this method.
		/// </summary>
		/// <param name="predicate">The predicate.</param>
		public MethodOption<T1> Condition(Func<T1, bool> predicate)
		{
			mockedFunction.Condition = predicate;
			return this;
		}

		/// <summary>
		/// The mocking method.
		/// </summary>
		public Option Do(Action<T1> method)
		{
			mockedFunction.Function = method;
			return this;
		}
	}


	public class MethodOption<T1, T2> : Option
	{
		public MethodOption(MockedFunction mockedFunction) 
			: base(mockedFunction) { }

		public MethodOption<T1, T2> Condition(Func<T1, T2, bool> predicate)
		{
			mockedFunction.Condition = predicate;
			return this;
		}
		public Option Do(Action<T1, T2> method)
		{
			mockedFunction.Function = method;
			return this;
		}
	}

	public class MethodOption<T1, T2, T3> : Option
	{
		public MethodOption(MockedFunction mockedFunction) 
			: base(mockedFunction) { }

		public MethodOption<T1, T2, T3> Condition(Func<T1, T2, T3, bool> predicate)
		{
			mockedFunction.Condition = predicate;
			return this;
		}
		public Option Do(Action<T1, T2, T3> method)
		{
			mockedFunction.Function = method;
			return this;
		}
	}

	public class MethodOption<T1, T2, T3, T4> : Option
	{
		public MethodOption(MockedFunction mockedFunction) 
			: base(mockedFunction) { }

		public MethodOption<T1, T2, T3, T4> Condition(Func<T1, T2, T3, T4, bool> predicate)
		{
			mockedFunction.Condition = predicate;
			return this;
		}
		public Option Do(Action<T1, T2, T3, T4> method)
		{
			mockedFunction.Function = method;
			return this;
		}
	}
}
